package com.example.yb.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.yb.entity.Iyqww_yb_wbssb_ssb;
import com.example.yb.entity.Iyqww_yb_wbssb_ssbVo;
import com.example.yb.entity.Sheet4;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author
 * @createtime 2021-08-14 9:20
 * @description
 */
@Mapper
@Component
public interface YB_ssbMapper {

    ArrayList<Iyqww_yb_wbssb_ssb> findAddress();

    void addForeignId(@Param("foreignId") String str, @Param("address") String address);

    List<Map<String, Object>> staticData(@Param("foreignId") String foreignId);


    @Select("SELECT a.address,a.foreignId,a.sequenceStatus,a.ShortText1608803337156," +
            "a.ShortText1608772055540,a.ShortText1608772160647,a.ShortText1608777161506," +
            "a.ShortText1608796211477,a.ShortText1608799766004,a.ShortText1608801262580," +
            "a.ShortText1608801569614,a.ShortText1608801859045,b.startTime," +
            "b.finishTime FROM iyqww_yb_wbssb_ssb a LEFT JOIN biz_workitem_finished b ON a.workflowInstanceId = b.instanceId " +
            "where foreignId = #{foreignId} AND sequenceStatus =\"COMPLETED\"")
    List<Iyqww_yb_wbssb_ssbVo> queryAllSsbVo(Page<Iyqww_yb_wbssb_ssbVo> pagination, @Param("foreignId") String foreignId);

    @Select("SELECT a.address,a.foreignId,a.sequenceStatus,a.ShortText1608803337156," +
            "a.ShortText1608772055540,a.ShortText1608772160647,a.ShortText1608777161506," +
            "a.ShortText1608796211477,a.ShortText1608799766004,a.ShortText1608801262580," +
            "a.ShortText1608801569614,a.ShortText1608801859045,b.participantName,b.receiveTime," +
            "b.activityName FROM iyqww_yb_wbssb_ssb a LEFT JOIN biz_workitem b ON " +
            "a.workflowInstanceId = b.instanceId where foreignId = #{foreignId} AND sequenceStatus!=\"COMPLETED\"")
    List<Iyqww_yb_wbssb_ssbVo> queryAllSsbVo1(Page<Iyqww_yb_wbssb_ssbVo> pagination, @Param("foreignId") String foreignId);

    @Insert("INSERT INTO iyqww_yb_wbssb_ssbvo (foreignId,userName,mobile,address,addressJwd,deptName,sequenceStatus) VALUES(#{foreignId},#{userName},#{mobile},#{address},#{addressJwd},#{deptName},#{sequenceStatus})")
    void add_ssbVo(Iyqww_yb_wbssb_ssbVo ssbVo);

    @Select("select foreignId,userName,mobile,address,addressJwd,deptName,sequenceStatus from iyqww_yb_wbssb_ssbvo")
    List<Iyqww_yb_wbssb_ssbVo> selectAll();


    @Select("select foreignId,addressJwd from sheet4")
    List<Sheet4> findAll();

    @Update("UPDATE iyqww_yb_wbssb_ssbvo SET addressJwd=#{addressJwd} WHERE foreignId=#{foreignId}")
    void addSsbvo(@Param("addressJwd") String addressJwd,@Param("foreignId") String foreignId);


}
